package gao.xiaolei.dao;

import gao.xiaolei.entity.Role;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository("RoleDao")
public interface RoleDao extends JpaRepository<Role, String> {

    @Query(value = "from Role where id= :id")
    public Role queryById(@Param("id") String id);

    public Role findByName(String name);

    public Role findByNameOrChineseName(String name, String ChineseName);

    @Query("select id from Role where name in:names")
    public List<String> getAllIdByNameIn(@Param("names") List<String> names);

    @Query("select id from Role where name =:name")
    public String getIdByName(@Param("name") String name);

    @Query("select chineseName from Role where id=:id")
    public String getChineseName(@Param("id") String id);

}
